
namespace Api.Dto;

public class ApiResultDto<T>
{
    public int Code { get; set; }
    public string Msg { get; set; } = null!;
    public T? Data { get; set; }

    public ApiResultDto(int code, string msg, T? data)
    {
        Code = code;
        Msg = msg;
        Data = data;
    }

    public static ApiResultDto<T> Success(T? data, string msg = "成功")
    {
        int code = 1000;
        return new ApiResultDto<T>(code, msg, data);
    }

    public static ApiResultDto<T> Error(int code =1002,string msg = "失败")
    {
        return new ApiResultDto<T>(code, msg, default);
    }
}